* This file models public perception of the threat by sector

* data cleaning in Stata
clear all
set more off
use "/Users/paulmusgrave/Dropbox/0001 Academic Projects/Ongoing/0148 The Cyber/Revised Work/Data/CCESUsable.dta"
set scheme plottigblind

cd "/Users/paulmusgrave/Dropbox/0001 Academic Projects/Ongoing/0148 The Cyber/Revised Work/Tables"

* Voting Systems vulnerability
 quietly ologit vulnerablevote white female college age i.newsintadj i.internethome i.pid7
eststo vulnerablevoteALL
 quietly ologit vulnerablevote white female college age i.newsintadj i.internethome if gop7 == 1
eststo vulnerablevoteGOP7
 quietly ologit vulnerablevote white female college age i.newsintadj i.internethome if dem7 == 1
eststo vulnerablevoteDEM7
 quietly ologit vulnerablevote white female college age i.newsintadj i.internethome if ind7 == 1
eststo vulnerablevoteIND7

esttab vulnerablevoteALL vulnerablevoteGOP7 vulnerablevoteDEM7 vulnerablevoteIND7  ///
	using Tab2OlogitVotingMachineVulnerabilityByPartyPID7.rtf, ///
	label replace  ///
	wrap  onecell compress ///
	mtitles("All Respondents" "Republicans" "Democrats" "Independent") ///
	title("Ordinal Logit Models of Perceptions of Voting Machine Vulnerability") ///
	refcat(0.newsintadj "News Interest" ///
			1.internethome "Internet at Home" ///
			1.pid7 "Party ID", nolabel) ///
	nodepvars

	
* Power Grid vulnerability
 quietly ologit vulnerablepower white female college age i.newsintadj i.internethome i.pid7
eststo vulnerablepowerALL
 quietly ologit vulnerablepower white female college age i.newsintadj i.internethome if gop7 == 1
eststo vulnerablepowerGOP7
 quietly ologit vulnerablepower white female college age i.newsintadj i.internethome if dem7 == 1
eststo vulnerablepowerDEM7
 quietly ologit vulnerablepower white female college age i.newsintadj i.internethome if ind7 == 1
eststo vulnerablepowerIND7


esttab vulnerablepowerALL vulnerablepowerGOP7 vulnerablepowerDEM7 vulnerablepowerIND7  ///
	using Tab2OlogitPowerGridVulnerabilityByPartyPID7.rtf, ///
	label replace nobaselevels ///
	wrap  onecell compress ///
	mtitles("All Respondents" "Republicans" "Democrats" "Independent") ///
	coeflabels(white "White" female "Female" college "College" ///
	age "Age" newsintadj "News Interest" i.internethome "Internet at Home") ///
	title("Ordinal Logit Models of Perceptions of Power Grid Vulnerability") ///
	nodepvars
	
* Major Corp vulnerability
 quietly ologit vulnerablecorp white female college age i.newsintadj i.internethome i.pid7
eststo vulnerablecorpALL
 quietly ologit vulnerablecorp white female college age i.newsintadj i.internethome if gop7 == 1
eststo vulnerablecorpGOP7
 quietly ologit vulnerablecorp white female college age i.newsintadj i.internethome if dem7 == 1
eststo vulnerablecorpDEM7
 quietly ologit vulnerablecorp white female college age i.newsintadj i.internethome if ind7 == 1
eststo vulnerablecorpIND7


esttab vulnerablecorpALL vulnerablecorpGOP7 vulnerablecorpDEM7 vulnerablecorpIND7  ///
	using Tab2OlogitCorpVulnerabilityByPartyPID7.rtf, ///
	label replace nobaselevels ///
	wrap  onecell compress ///
	mtitles("All Respondents" "Republicans" "Democrats" "Independent") ///
	coeflabels(white "White" female "Female" college "College" ///
	age "Age" newsintadj "News Interest" i.internethome "Internet at Home") ///
	title("Ordinal Logit Models of Perceptions of Major Corporation Vulnerability") ///
	nodepvars


* Fed Govt vulnerability
 quietly ologit vulnerablefed white female college age i.newsintadj i.internethome
eststo vulnerablefedALL
 quietly ologit vulnerablefed white female college age i.newsintadj i.internethome if gop7 == 1
eststo vulnerablefedGOP7
 quietly ologit vulnerablefed white female college age i.newsintadj i.internethome if dem7 == 1
eststo vulnerablefedDEM7
 quietly ologit vulnerablefed white female college age i.newsintadj i.internethome if ind7 == 1
eststo vulnerablefedIND7


esttab vulnerablefedALL vulnerablefedGOP7 vulnerablefedDEM7 vulnerablefedIND7  ///
	using Tab2OlogitFedVulnerabilityByPartyPID7.rtf, ///
	label replace nobaselevels ///
	wrap  onecell compress ///
	mtitles("All Respondents" "Republicans" "Democrats" "Independent") ///
	coeflabels(white "White" female "Female" college "College" ///
	age "Age" newsintadj "News Interest" i.internethome "Internet at Home") ///
	title("Ordinal Logit Models of Perceptions of Federal Government Corporation Vulnerability") ///
	nodepvars


* Military vulnerability
 quietly ologit vulnerablemil white female college age i.newsintadj i.internethome 
eststo vulnerablemilALL
 quietly ologit vulnerablemil white female college age i.newsintadj i.internethome if gop7 == 1
eststo vulnerablemilGOP7
 quietly ologit vulnerablemil white female college age i.newsintadj i.internethome if dem7 == 1
eststo vulnerablemilDEM7
 quietly ologit vulnerablemil white female college age i.newsintadj i.internethome if ind7 == 1
eststo vulnerablemilIND7


esttab vulnerablemilALL vulnerablemilGOP7 vulnerablemilDEM7 vulnerablemilIND7  ///
	using Tab2OlogitMilitaryVulnerabilityByPartyPID7.rtf, ///
	label replace nobaselevels ///
	wrap  onecell compress ///
	mtitles("All Respondents" "Republicans" "Democrats" "Independent") ///
	coeflabels(white "White" female "Female" college "College" ///
	age "Age" newsintadj "News Interest" i.internethome "Internet at Home") ///
	title("Ordinal Logit Models of Perceptions of Military Vulnerability") ///
	nodepvars
	
*************
* Coefplots


coefplot(vulnerablevoteALL, label(All Respondents)) /// 
		(vulnerablevoteGOP7, label(Republicans) offset(.15)) /// 
		(vulnerablevoteDEM7, label(Democrats) offset(-.15)), ///
		drop(_cons age white college female *.pid7 *.internethome) xline(0) ///
		title("Voting Machine",size(small)) ///
				 baselevels ///
		headings(0.newsintadj="{bf:News Interest}" ///
				1.internethome="{bf:Internet Access}") ///
					legend(rows(1) pos(6)) ///
					name(vulnerablevote) nodraw
			

coefplot(vulnerablemilALL, label(All Respondents)) /// 
		(vulnerablemilGOP7, label(Republicans) offset(.15)) /// 
		(vulnerablemilDEM7, label(Democrats) offset(-.15)), ///
		drop(_cons age white college female *.pid7 *.internethome) xline(0) ///
		title("Military",size(small)) ///
				 baselevels ///
		headings(0.newsintadj="{bf:News Interest}" ///
				1.internethome="{bf:Internet Access}") ///
			name(vulnerablemil) nodraw legend(off)
			

coefplot(vulnerablefedALL, label(All Respondents)) /// 
		(vulnerablefedGOP7, label(Republicans) offset(.15)) /// 
		(vulnerablefedDEM7, label(Democrats) offset(-.15)), ///
		drop(_cons age white college female *.pid7 *.internethome) xline(0) ///
		title("Federal Government",size(small)) ///
				 baselevels ///
		headings(0.newsintadj="{bf:News Interest}" ///
				1.internethome="{bf:Internet Access}") ///
		name(vulnerablefed) nodraw legend(off)
			

coefplot(vulnerablecorpALL, label(All Respondents)) /// 
		(vulnerablecorpGOP7, label(Republicans) offset(.15)) /// 
		(vulnerablecorpDEM7, label(Democrats) offset(-.15)), ///
		drop(_cons age white college female *.pid7 *.internethome) xline(0) ///
		title("Major Corporations",size(small)) ///
				 baselevels ///
		headings(0.newsintadj="{bf:News Interest}" ///
				1.internethome="{bf:Internet Access}") ///
			name(vulnerablecorp) nodraw legend(off)

			
coefplot(vulnerablepowerALL, label(All Respondents)) /// 
		(vulnerablepowerGOP7, label(Republicans) offset(.15)) /// 
		(vulnerablepowerDEM7, label(Democrats) offset(-.15)), ///
		drop(_cons age white college female *.pid7 *.internethome) xline(0) ///
		title("Power Grid",size(small)) ///
				 baselevels ///
		headings(0.newsintadj="{bf:News Interest}" ///
				1.internethome="{bf:Internet Access}") ///
			name(vulnerablepower) nodraw 


cd "/Users/paulmusgrave/Dropbox/0001 Academic Projects/Ongoing/0148 The Cyber/Revised Work/Charts"

grc1leg vulnerablevote vulnerablemil vulnerablecorp vulnerablefed ///
		vulnerablepower, ycommon xcommon ///
		title("News Interest and Perceptions of Sector Vulnerability, by Party") ///
		subtitle("Ordered Logit Coefficients", size(vsmall)) rows(3)  ///
		name(vulnerabletogether, replace) 

graph display vulnerabletogether, xsize(7) ysize(10)

graph export "Figure2OlogitSelectedCoefficients.png", width(2000) replace
graph export "Figure2OlogitSelectedCoefficients.ps", orientation(portrait) replace
